package io;


import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * 使用对象输入流进行反序列化
 */
public class OISDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        FileInputStream fis = new FileInputStream("javaSE/person.obj");
        ObjectInputStream ois = new ObjectInputStream(fis);
        /*
            反序列化对象
            该方法可能会抛出异常:java.io.InvalidClassException
         */
        Person p = (Person)ois.readObject();
        System.out.println(p);

        System.out.println(p.getName());

        ois.close();

    }
}
